//
//  FXCRetweetedView.m
//  XinLangFeiBo
//
//  Created by dllo on 16/3/5.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FXCRetweetedView.h"

#import "FXCStatus.h"
#import "FXCStatusFrame.h"
#import "FXCUser.h"

#import "FXCPhotosView.h"


@interface FXCRetweetedView ()

@property (nonatomic, weak) UILabel *nameLabel;

@property (nonatomic, weak)  UILabel *textLabel;

@property (nonatomic, weak)  FXCPhotosView *photosView;

@end
@implementation FXCRetweetedView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        // 添加所有子控件
        [self setUpAllSubviews];
        
        self.userInteractionEnabled = YES;
//        self.image = [UIImage resizableWithImageName:@"timeline_retweet_background"];
        self.image = [UIImage imageNamed:@"timeline_retweet_background"];
        self.image = [self.image stretchableImageWithLeftCapWidth:self.image.size.width * 0.5 topCapHeight:self.image.size.height * 0.5];
        
    }
    return self;
}

- (void)setUpAllSubviews
{
    // 昵称
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.textColor = FXCColor(85, 105, 144);
    _nameLabel = nameLabel;
    nameLabel.font = FXCNameFont;
    [self addSubview:nameLabel];
    
    // 内容
    UILabel *textLabel = [[UILabel alloc] init];
    _textLabel.font = FXCTextFont;
    _textLabel = textLabel;
    textLabel.numberOfLines = 0;
    [self addSubview:textLabel];
    
    // 配图
    FXCPhotosView *photosView = [[FXCPhotosView alloc] init];
    [self addSubview:photosView];
    _photosView = photosView;
    
}




- (void)setStatusF:(FXCStatusFrame *)statusF
{
    _statusF = statusF;
    FXCStatus *s = statusF.status;
    
    self.frame = statusF.retweetedViewF;
    
    // 昵称
    _nameLabel.text = [NSString stringWithFormat:@"@%@",s.retweeted_status.user.name];
    _nameLabel.frame = statusF.retweetNameViewF;
    
    // 内容
    _textLabel.text= s.retweeted_status.text;
    _textLabel.frame = statusF.retweetTextViewF;
    
    // 配图
    if (s.retweeted_status.pic_urls.count) { // 有配图
        _photosView.pic_urls = s.retweeted_status.pic_urls;
        _photosView.frame = statusF.retweetPhotosViewF;
        _photosView.hidden = NO;
    }else{
        _photosView.hidden = YES;
    }
    
}


@end
